<?php
defined('IN_IXDCW') or exit('Access Denied');
$do = new ReviewModule();
$menus = array (
    array('评论列表', '?moduleid='.$moduleid.'&file='.$file),
    array('评论审核', '?moduleid='.$moduleid.'&file='.$file.'&action=check'),
    array('评论设置', '?moduleid='.$moduleid.'&file=setting#comment'),
);
$this_forward = '?moduleid='.$moduleid.'&file='.$file;
if(in_array($action, array('', 'check'))) {
	$sfields = array('内容', '原文ID',  '会员名', 'IP', '评论ID');
	$dfields = array('content', 'item_id',  'username', 'ip',  'itemid');
	$sorder  = array('结果排序方式', '添加时间降序', '添加时间升序',);
	$dorder  = array('itemid desc', 'addtime DESC', 'addtime ASC');
	isset($fields) && isset($dfields[$fields]) or $fields = 0;
	isset($order) && isset($dorder[$order]) or $order = 0;
	isset($ip) or $ip = '';
	$mid = isset($mid) ? intval($mid) : 0;
	$item_module = $MODULE[$mid]['module'];
	$fields_select = dselect($sfields, 'fields', '', $fields);
	$module_select = review_select('mid', '所有模块', $mid,$MOD['review_module']);
	$order_select  = dselect($sorder, 'order', '', $order);
	$condition = '';
	if($keyword) $condition .= in_array($dfields[$fields], array('item_id', 'itemid', 'ip')) ? " AND $dfields[$fields]='$kw'" : " AND $dfields[$fields] LIKE '%$keyword%'";
	if($psize) $do->setPagesize($psize);
	if($item_module) $condition .= " AND item_module='$item_module'";
	if($ip) $condition .= " AND ip='$ip'";
}
switch($action) {
	case 'delete':
		$itemid or msg('请选择评论');
		$do->delete($itemid);
		dmsg('删除成功', $this_forward);
	break;
	case 'check':
		if($itemid) {
			$status = $status == 3 ? 3 : 2;
			$do->check($itemid, $status);
			dmsg($status == 3 ? '审核成功' : '取消成功', $forward);
		} else {
			$lists = $do->getlist('status=2'.$condition, $dorder[$order]);
			$menuid = 1;
			include tpl('review', $module);
		}
	break;
	default:
		$lists = $do->getlist('status=3'.$condition, $dorder[$order]);
		$menuid = 0;
		include tpl('review', $module);
	break;
}
?>